package com.suse.warmstill.common.exception;


import com.suse.warmstill.common.enums.ResponseEnum;

/**
 * 全局业务异常
 *
 * @author admin
 */
public class BusinessException extends RuntimeException {

    /**
     * 异常代码
     */
    private final int code;

    /**
     * 异常信息
     */
    private final String message;

    public BusinessException(int code, String msg) {

        super(msg);
        this.code = code;
        this.message = msg;
    }

    public BusinessException(ResponseEnum responseEnum) {

        super(responseEnum.getMsg());
        this.code = responseEnum.getCode();
        this.message = responseEnum.getMsg();
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
